﻿using Autofac.Annotation;
using Micro.Extensions.SqlSugar.Base;
using Micro.Extensions.SqlSugar.UnitOfWork;
using Module.Test.Domain.IRepositorys;
using Module.Test.Domain.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Module.Test.Infrastructure.Repository
{
    //[Component(AutofacScope = AutofacScope.InstancePerLifetimeScope)]
    public class CustomRepository : BaseRepository<Custom>, ICustomRepository
    {
        public CustomRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
        {
        }

        public async Task<bool> ExistName(string name)
        {
            var result =await this.Table.AnyAsync(m => m.Name == name);
            return result;
        }

        public async Task<bool> ExistName(long id, string name)
        {
            var result = await this.Table.AnyAsync(m => m.Id != id && m.Name == name);
            return result;
        }
    }
}
